#ifndef _XF_CONVERT_HPP_
#define _XF_CONVERT_HPP_

#include <ros/ros.h>
#include <xf_control/xf_control.h>

typedef struct WordsData {
    int    score;
    int    words[3];
    int    scores[3];// 动作　｜　颜色　｜　物体
}WordsData;

class xf_Convertor
{
public:
    static bool toMessage(const WordsData& data, const double timestamp, xf_control::xf_control& msg)
    {
        msg.header.stamp.fromSec(timestamp);
        msg.header.frame_id = "xf_control";

        msg.score = data.score;
        for(int i = 0;i < 3; i++)
        {
            msg.words.push_back(data.words[i]);
            msg.scores.push_back(data.scores[i]);
        }
        return true;
    }

    static bool toData(const xf_control::xf_control& msg, WordsData& data, double timestamp)
    {
        timestamp = msg.header.stamp.toSec();

        data.score = msg.score;
        for(int i = 0;i < 3; i++)
        {
            data.words[i] = msg.words[i];
            data.scores[i] = msg.scores[i];
        }
    }

};

#endif